/*******************************************************************************
 * Copyright 2011-2013 Sergey Tarasevich
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package com.cloudcc.mobile.util.photo;

import android.graphics.Bitmap;
import android.os.Handler;

import com.cloudcc.mobile.R;
import com.cloudcc.mobile.manager.RunTimeManager;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;

/**
 * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
 */
public final class Constants {
	public static ImageLoader imageLoader = ImageLoader.getInstance();
	public static DisplayImageOptions IM_IMAGE_OPTIONS = new DisplayImageOptions.Builder()
			.showImageOnLoading(R.drawable.ic_chat_def_pic)
			.showImageForEmptyUri(R.drawable.ic_chat_def_pic)
			.showImageOnFail(R.drawable.ic_chat_def_pic)
			.bitmapConfig(Bitmap.Config.RGB_565)
			.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
			.displayer(new RoundedBitmapDisplayer(dp2pxxCon(6))) // default 可以设置动画，比如圆角或者渐变
			.cacheInMemory(true).cacheOnDisc(true).build();
	public static DisplayImageOptions image_display_options = new DisplayImageOptions.Builder()
			.showImageOnLoading(R.drawable.chat_loading)
			.showImageForEmptyUri(R.drawable.chat_loading)
			.showImageOnFail(R.drawable.chat_loading)
			.bitmapConfig(Bitmap.Config.RGB_565)
			.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
			.cacheInMemory(false).cacheOnDisc(true).build();
	public static DisplayImageOptions options = new DisplayImageOptions.Builder()
			.showImageOnLoading(R.drawable.chat_loading)
			.showImageForEmptyUri(R.drawable.chat_loading)
			.showImageOnFail(R.drawable.chat_loading)
			// 不是<strong>图片</strong>文件 显示<strong>图片</strong>
			.resetViewBeforeLoading(false)
			// default
			.showImageOnFail(R.drawable.chat_loading)
			.bitmapConfig(Bitmap.Config.RGB_565)
			.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
			// default
			.displayer(new SimpleBitmapDisplayer())
			// default 可以设置动画，比如圆角或者渐变
			.handler(new Handler()).cacheInMemory(false).cacheOnDisc(false)
			.build();

	// 3.DisplayImageOptions实例对象的配置
	// 以下的设置再调用displayImage()有效，使用loadImage()无效
	public static DisplayImageOptions Contact_options = new DisplayImageOptions.Builder()
			.showImageForEmptyUri(R.drawable.person110)
			// empty URI时显示的<strong>图片</strong>
			.showImageOnFail(R.drawable.person110)
			// 不是<strong>图片</strong>文件 显示<strong>图片</strong>
			.showImageOnLoading(R.drawable.person110)
			.resetViewBeforeLoading(false)
			// default
			.bitmapConfig(Bitmap.Config.RGB_565).delayBeforeLoading(1000)
			.cacheInMemory(true) // default 不缓存至内存
			.cacheOnDisc(true) // default 不缓存至手机SDCard
			.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)// default
			.handler(new Handler())
			// default
			.build();
	// 首页图片使用的配置
	// 以下的设置再调用displayImage()有效，使用loadImage()无效
	public static DisplayImageOptions Index_options = new DisplayImageOptions.Builder()
			.showStubImage(R.drawable.chat_loading)
			// image在加载过程中，显示的<strong>图片</strong>
			.showImageForEmptyUri(R.drawable.chat_loading)
			// empty URI时显示的<strong>图片</strong>
			.showImageOnFail(R.drawable.chat_loading)
			// 不是<strong>图片</strong>文件 显示<strong>图片</strong>
			.resetViewBeforeLoading(false)
			// default
			.bitmapConfig(Bitmap.Config.RGB_565)
			.imageScaleType(ImageScaleType.IN_SAMPLE_INT)
			.delayBeforeLoading(1000).cacheInMemory(false) // default 不缓存至内存
			.cacheOnDisc(false) // default 不缓存至手机SDCard
			.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)// default
			.bitmapConfig(Bitmap.Config.ARGB_8888) // default
			.handler(new Handler())
			// default
			.build();

	public static DisplayImageOptions chater_index_icon_optionst = new DisplayImageOptions.Builder()
			.showStubImage(R.drawable.person110)
			// image在加载过程中，显示的<strong>图片</strong>
			.showImageForEmptyUri(R.drawable.person110)
			// empty URI时显示的<strong>图片</strong>
			.showImageOnFail(R.drawable.person110)
			// 不是<strong>图片</strong>文件 显示<strong>图片</strong>
			.resetViewBeforeLoading(false)
			// default
			.bitmapConfig(Bitmap.Config.RGB_565).delayBeforeLoading(1000)
			.cacheInMemory(true).imageScaleType(ImageScaleType.EXACTLY)// default
			.cacheOnDisc(true).build();
	/**
	 * chat首页内容图片
	 */
	public static DisplayImageOptions chater_index_option_image = new DisplayImageOptions.Builder()
			.showStubImage(R.drawable.chat_loading) // image在加载过程中，显示的<strong>图片</strong>
			.showImageForEmptyUri(R.drawable.chat_loading) // empty
															// URI时显示的<strong>图片</strong>
			.showImageOnFail(R.drawable.chat_loading) // 不是<strong>图片</strong>文件
														// 显示<strong>图片</strong>
			.resetViewBeforeLoading(false) // default
			.delayBeforeLoading(1000).cacheInMemory(true) // default 不缓存至内存
			.cacheOnDisc(false) // default 不缓存至手机SDCard
			.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)// default
			.build();
	/**
	 * chat首页内容图片
	 */
	public static DisplayImageOptions qiandao_image = new DisplayImageOptions.Builder()
			.showStubImage(R.drawable.chat_loading)
			// image在加载过程中，显示的<strong>图片</strong>
			.showImageForEmptyUri(R.drawable.chat_loading)
			// empty URI时显示的<strong>图片</strong>
			.showImageOnFail(R.drawable.chat_loading)
			// 不是<strong>图片</strong>文件 显示<strong>图片</strong>
			.resetViewBeforeLoading(false)
			// default
			.bitmapConfig(Bitmap.Config.RGB_565).delayBeforeLoading(1000)
			.cacheInMemory(true) // default 不缓存至内存
			.cacheOnDisc(false) // default 不缓存至手机SDCard
			.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)// default
			.handler(new Handler()) // default
			.build();

	public static class Config {
		public static final boolean DEVELOPER_MODE = false;
	}
	public static int dp2pxxCon(float dipValue) {
		return (int) (dipValue * RunTimeManager.getInstance().getScale() + 0.5f);
	}
}
